/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Pojo;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author jeferson
 */
@Entity
@Table(name = "TB_CARGO", catalog = "musical", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TbCargo.findAll", query = "SELECT t FROM TbCargo t"),
    @NamedQuery(name = "TbCargo.findByCarCodigo", query = "SELECT t FROM TbCargo t WHERE t.carCodigo = :carCodigo"),
    @NamedQuery(name = "TbCargo.findByCarDescricao", query = "SELECT t FROM TbCargo t WHERE t.carDescricao = :carDescricao"),
    @NamedQuery(name = "TbCargo.findByCarSalbase", query = "SELECT t FROM TbCargo t WHERE t.carSalbase = :carSalbase")})
public class TbCargo implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "CAR_CODIGO")
    private Long carCodigo;
    @Basic(optional = false)
    @Column(name = "CAR_DESCRICAO")
    private String carDescricao;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @Column(name = "CAR_SALBASE")
    private BigDecimal carSalbase;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "venCodcargo")
    private List<TbVendedor> tbVendedorList;

    public TbCargo() {
    }

    public TbCargo(Long carCodigo) {
        this.carCodigo = carCodigo;
    }

    public TbCargo(Long carCodigo, String carDescricao, BigDecimal carSalbase) {
        this.carCodigo = carCodigo;
        this.carDescricao = carDescricao;
        this.carSalbase = carSalbase;
    }

    public Long getCarCodigo() {
        return carCodigo;
    }

    public void setCarCodigo(Long carCodigo) {
        Long oldCarCodigo = this.carCodigo;
        this.carCodigo = carCodigo;
        changeSupport.firePropertyChange("carCodigo", oldCarCodigo, carCodigo);
    }

    public String getCarDescricao() {
        return carDescricao;
    }

    public void setCarDescricao(String carDescricao) {
        String oldCarDescricao = this.carDescricao;
        this.carDescricao = carDescricao;
        changeSupport.firePropertyChange("carDescricao", oldCarDescricao, carDescricao);
    }

    public BigDecimal getCarSalbase() {
        return carSalbase;
    }

    public void setCarSalbase(BigDecimal carSalbase) {
        BigDecimal oldCarSalbase = this.carSalbase;
        this.carSalbase = carSalbase;
        changeSupport.firePropertyChange("carSalbase", oldCarSalbase, carSalbase);
    }

    @XmlTransient
    public List<TbVendedor> getTbVendedorList() {
        return tbVendedorList;
    }

    public void setTbVendedorList(List<TbVendedor> tbVendedorList) {
        this.tbVendedorList = tbVendedorList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (carCodigo != null ? carCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TbCargo)) {
            return false;
        }
        TbCargo other = (TbCargo) object;
        if ((this.carCodigo == null && other.carCodigo != null) || (this.carCodigo != null && !this.carCodigo.equals(other.carCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.carDescricao;
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
